/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright(c) 2021 Huawei Technologies Co., Ltd */

#ifndef HINIC3_BOND_H
#define HINIC3_BOND_H

#include <linux/netdevice.h>
#include <linux/types.h>

enum hinic3_bond_user {
	HINIC3_BOND_USER_OVS,
	HINIC3_BOND_USER_TOE,
	HINIC3_BOND_USER_ROCE,
	HINIC3_BOND_USER_NUM
};

enum bond_service_proc_pos {
	BOND_BEFORE_ACTIVE,
	BOND_AFTER_ACTIVE,
	BOND_BEFORE_MODIFY,
	BOND_AFTER_MODIFY,
	BOND_BEFORE_DEACTIVE,
	BOND_AFTER_DEACTIVE,
	BOND_POS_MAX
};

#define HINIC3_MAX_PORT 4
#define HINIC3_IFNAMSIZ 16
struct hinic3_bond_info_s {
	u8 slaves;
	u8 cnt;
	u8 srv[2];
	char slaves_name[HINIC3_MAX_PORT][HINIC3_IFNAMSIZ];
};

/* 与ovs_bond_cmd_s结构体的非name部分保持一致 */
struct bond_attr {
	u16 bond_mode;
	u16 bond_id;
	u16 up_delay;
	u16 down_delay;
	u8 active_slaves;
	u8 slaves;
	u8 lacp_collect_slaves;
	u8 xmit_hash_policy;
	u32 first_roce_func;
};

int hinic3_bond_attach(const char *name, enum hinic3_bond_user user, u16 *bond_id);
int hinic3_bond_detach(u16 bond_id, enum hinic3_bond_user user);
void hinic3_bond_clean_user(enum hinic3_bond_user user);
int hinic3_bond_get_uplink_id(u16 bond_id, u32 *uplink_id);
int hinic3_bond_register_service_func(enum hinic3_bond_user user, void (*func)
				      (const char *bond_name, void *bond_attr,
				      enum bond_service_proc_pos pos));
int hinic3_bond_unregister_service_func(enum hinic3_bond_user user);
int hinic3_bond_get_slaves(u16 bond_id, struct hinic3_bond_info_s *info);
#endif /* HINIC3_BOND_H */
